home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1996 February / EnigmA AMIGA RUN 04 (1996)(G.R. Edizioni)(IT)[!][issue 1996-02][Skylink CD III].iso / earcd / midi / ptrply65.lha / PTReplay / examples / control_temp.c < prev    next >
C/C++ Source or Header  |  1994-12-30  |  3KB  |  151 lines

  1.  
  2. #include <exec/types.h>
  3. #include <utility/tagitem.h>
  4. #include <libraries/asl.h>
  5. #include <libraries/gadtools.h>
  6. #include <intuition/intuition.h>
  7. #include <string.h>
  8.  
  9. #include <clib/dos_protos.h>
  10. #include <clib/asl_protos.h>
  11. #include <clib/gadtools_protos.h>
  12. #include <pragmas/dos_pragmas.h>
  13. #include <pragmas/asl_pragmas.h>
  14. #include <pragmas/gadtools_pragmas.h>
  15.  
  16. #include "control.h"
  17. #include "/include/ptreplay_protos.h"
  18. #include "/include/ptreplay_pragmas.h"
  19. #include "/include/ptreplay.h"
  20.  
  21. int PlayClicked( void )
  22. {
  23.     /* routine when gadget "_Play" is clicked. */
  24.     PTPlay(Mod);
  25.  
  26.     return(TRUE);
  27. }
  28.  
  29. int StopClicked( void )
  30. {
  31.     /* routine when gadget "_Stop" is clicked. */
  32.     PTStop(Mod);
  33.  
  34.     return(TRUE);
  35. }
  36.  
  37. int QuitClicked( void )
  38. {
  39.     /* routine when gadget "_Quit" is clicked. */
  40.     if(Mod)
  41.     {
  42.         PTStop(Mod);
  43.         PTUnloadModule(Mod);
  44.     }
  45.     return(FALSE);
  46. }
  47.  
  48. int PauseClicked( void )
  49. {
  50.     /* routine when gadget "P_ause" is clicked. */
  51.     if(Paused)
  52.         PTResume(Mod);
  53.     else
  54.         PTPause(Mod);
  55.  
  56.     Paused=~Paused;
  57.  
  58.     return(TRUE);
  59. }
  60.  
  61. int LoadClicked( void )
  62. {
  63. char Buffer[256];
  64. UBYTE Len;
  65.  
  66.     PTStop(Mod);
  67.  
  68.     if(AslRequestTags(FileReq, ASLFR_Window, ControlWnd,TAG_DONE))
  69.     {
  70.         strcpy(Buffer, FileReq->rf_Dir);
  71.         AddPart(Buffer, FileReq->fr_File, 256);
  72.  
  73.         if(Mod=PTLoadModule(Buffer))
  74.         {
  75.             PTInstallBits(Mod, StopBit, PatternBit, -1, -1);
  76.             GT_SetGadgetAttrs(ControlGadgets[GD_Module], ControlWnd, NULL,
  77.                                 GTTX_Text, Mod->mod_Name, TAG_DONE);
  78.             Len=PTSongLen(Mod);
  79.             GT_SetGadgetAttrs(ControlGadgets[GD_Length], ControlWnd, NULL,
  80.                                 GTNM_Number, Len, TAG_DONE );
  81.             GT_SetGadgetAttrs(ControlGadgets[GD_Pos], ControlWnd, NULL,
  82.                                 GTNM_Number, 0l, TAG_DONE);
  83.         }
  84.     }
  85.  
  86.     return(TRUE);
  87. }
  88.  
  89. int FadeClicked( void )
  90. {
  91.     /* routine when gadget "_Fade" is clicked. */
  92.     PTStartFade(Mod,1);
  93.     return(TRUE);
  94. }
  95.  
  96. int LoopClicked( void )
  97. {
  98.     /* routine when gadget "L_oop" is clicked. */
  99.     Loop=ControlGadgets[GD_Loop]->Flags & GFLG_SELECTED;
  100.     return(TRUE);
  101. }
  102.  
  103. int ControlCloseWindow( void )
  104. {
  105.     /* routine for "IDCMP_CLOSEWINDOW". */
  106.     if(Mod)
  107.     {
  108.         PTStop(Mod);
  109.         PTUnloadModule(Mod);
  110.     }
  111.     return(FALSE);
  112. }
  113.  
  114. int ControlVanillaKey( void )
  115. {
  116.     /* routine for "IDCMP_VANILLAKEY". */
  117.     switch(ControlMsg.Code)
  118.     {
  119.         case 'p':
  120.         case 'P':
  121.             PlayClicked();
  122.             break;
  123.  
  124.         case 's':
  125.         case 'S':
  126.             StopClicked();
  127.             break;
  128.  
  129.         case 'q':
  130.         case 'Q':
  131.             QuitClicked();
  132.             break;
  133.  
  134.         case 'a':
  135.         case 'A':
  136.             PauseClicked();
  137.             break;
  138.  
  139.         case 'l':
  140.         case 'L':
  141.             LoadClicked();
  142.             break;
  143.  
  144.         case 'f':
  145.         case 'F':
  146.             FadeClicked();
  147.             break;
  148.     }
  149.     return(TRUE);
  150. }
  151.